﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <title>登录系统</title>
    <link href="@Url.Content("~/Content/css/bootstrap.min.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/css/bootstrap-responsive.min.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/css/unicorn.login.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/ligerUI/skins/Aqua/css/ligerui-all.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Content/ligerUI/js/ligerui.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Content/ligerUI/js/plugins/ligerDrag.js")"></script>
    <script src="@Url.Content("~/Content/ligerUI/js/plugins/ligerDialog.js")" type="text/javascript"></script>


    <script type="text/javascript">
        $(document).ready(function () {
            document.onkeydown = function (e) {
                var ev = document.all ? window.event : e;
                if (ev.keyCode == 13) {
                    loginfun();
                }
            }


            $("#btnLogin").click(function () {
                loginfun();
            });
        });

        function loginfun() {
            if ($("#username").val().trim().length <= 0) {
                $.ligerDialog.alert('请输入用户名', '提示消息', 'error');
                return false;
            }
            else if ($("#userpass").val().trim().length <= 0) {
                $.ligerDialog.alert('请输入密码', '提示消息', 'error');
                return false;
            }
            $.ajax({
                type: 'post',
                dataType: 'text',
                url: '@Url.Content("~/Manage/LoginAndRedirect")',
                data: { UserName: $("#username").val(), Password: $("#userpass").val() },
                success: function (result) {
                    if (result == "Error") {
                        $.ligerDialog.alert('登陆失败,用户名或密码错误', '提示消息', 'error');
                        $("#username").focus();
                        return;
                    }
                    else if (result == "Success")
                        location.href = "@Url.Content("~/Manage/Index")";
                },
                error: function (d, c, e) {
                    $.ligerDialog.alert('发送系统错误,请与系统管理员联系' + e, '提示消息', 'error');
                },
                beforeSend: function () {
                    $.ligerDialog.waitting("正在登陆中,请稍后...");
                    $("#btnLogin").attr("disabled", true);
                },
                complete: function () {
                    $.ligerDialog.closeWaitting();
                    $("#btnLogin").attr("disabled", false);
                }
            });
    }
    </script>
</head>
<body>
    <div id="logo">
        <img src="@Url.Content("~/Content/images/logo.png")" alt="" />
    </div>
    <div id="loginbox">
        <form id="loginform" class="form-vertical">
            <p>输入用户名和密码登录</p>
            <div class="control-group">
                <div class="controls">
                    <div class="input-prepend">
                        <span class="add-on"><i class="icon-user"></i></span>
                        <input type="text" id="username" value="admin" placeholder="用户名" />
                    </div>
                </div>
            </div>
            <div class="control-group">
                <div class="controls">
                    <div class="input-prepend">
                        <span class="add-on"><i class="icon-lock"></i></span>
                        <input type="password" id="userpass" value="admin" placeholder="密码" />
                    </div>
                </div>
            </div>
            <div class="form-actions">
                <span class="pull-left"><a href="#" class="flip-link" id="to-recover">忘记密码？</a></span>
                <span class="pull-right">
                    <input type="button" id="btnLogin" class="btn btn-inverse" value="登录" /></span>
            </div>
        </form>
    </div>
</body>
</html>
